import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'tool_base_widget.dart';

abstract class CatBaseWidgetPage extends StatefulWidget {
  @override
  CatBaseWidgetPageState createState() => getState();

  ///子类实现
  CatBaseWidgetPageState getState();
}

abstract class CatBaseWidgetPageState<T extends CatBaseWidgetPage> extends State<T> with BaseWidgetView{


  /*
  * push 到下一个控制器
  * */
  void popView(Widget item){
    Navigator.push(context, MaterialPageRoute(builder: (context){
      return item;
    }));
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      child: isBuild == false ? _isBuildDefault(context)
          : buildWidget(context),
    );
  }

  Widget _isBuildDefault(BuildContext context){
    size = MediaQuery.of(context).size;
    return Scaffold(
      appBar: buildAppBar(),
      body: buildWidget(context),);
  }
  Widget unBuild(BuildContext context){
    size = MediaQuery.of(context).size;
    return buildWidget(context);
  }


  // Widget buildWidget(BuildContext context);

  Widget buildAppBar() {
    return AppBar(
      backgroundColor: Colors.white,//设置导航背景颜色
      elevation: 1,
      title: Text(title,style: textStyle(),),
      leading: IconButton(icon: Icon(Icons.arrow_back_ios,),color: Colors.black,onPressed: (){
        Navigator.pop(context);
      },),
    );
  }

  Widget buildAppBarHome(title) {
    return AppBar(
      elevation: 1,
      title: Text(title,style: textStyle(),),
      backgroundColor: Colors.white,//设置导航背景颜色
      // leading: IconButton(icon: Icon(Icons.arrow_back_ios),onPressed: (){
      //   Navigator.pop(context);
      // },),
    );
  }

}